package com.way.Java多线程编程核心技术v2.chapter02_对象及变量的并发访问._2_2_synchronized同步语句块.不同步导致的逻辑错误及其解决方法;

/**
 * @PROJECT_NAME: my-projects
 * @DESCRIPTION:
 * @USER: 魏彪
 * @DATE: 2023/11/29 15:46
 */
public class Test {
    public static void main(String[] args) throws InterruptedException {
        MyOneList list = new MyOneList();
        Thread01 thread1 = new Thread01(list);
        thread1.setName("A");
        thread1.start();

        Thread02 thread2 = new Thread02(list);
        thread2.setName("B");
        thread2.start();

        Thread.sleep(6000);
        System.out.println("listSize=" + list.getSize());
    }
}
